package ch.bfh.ti.barcode.multiple;

/**
 * The SimpleFrame has only the frame number information in the header. It is
 * used for all the frames but the first one.
 * 
 * @author Dominik von Burg
 * 
 */
class SimpleFrame extends Frame {
	/**
	 * Creates a SimpleFrame by providing the user data and the frame number.
	 * The header of the frame is created with the frame number information.
	 * 
	 * @param data
	 *            The user data.
	 * @param frameNumber
	 *            The frame number.
	 */
	public SimpleFrame(byte[] data, int frameNumber) {
		frame = new byte[data.length + frameNumberSize];
		System.arraycopy(data, 0, frame, frameNumberSize, data.length);
		frame[0] = (byte) ((frameNumber << 24) >>> 24);
		frame[1] = (byte) ((frameNumber << 16) >>> 24);
	}

	/**
	 * Creates a SimpleFrame with the provided raw data of the frame. The frame
	 * number information has to be included in the header of the provided raw
	 * data.
	 * 
	 * @param data
	 *            The raw data of the frame.
	 */
	public SimpleFrame(byte[] data) {
		frame = data;
	}
}
